﻿Imports System.Net

Public Class frmLogin
    Public WithEvents Sock As Connections

    Private Sub do_enableBtn()
        btnLogin.Enabled = True
    End Sub

    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        frmMain.doLogin(txtUser.Text, txtPass.Text)
        If System.IO.File.Exists(My.Application.Info.DirectoryPath.ToString & "\client.xml") = False Then
            client_write_configuration()
        End If
        client_update_configuration(New Object(0) {}, _
                                    reconfig_server(ip, port, txtUser.Text, txtPass.Text, CheckEditAuto.Checked), _
                                    New Object(0) {})
        client_read_configuration()
        Me.Close()
    End Sub

    Private Sub txtUser_KeyDown(sender As Object, e As KeyEventArgs) Handles txtUser.KeyDown
        If e.KeyCode = Keys.Enter Then
            txtPass.Focus()
        End If
    End Sub

    Private Sub txtPass_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPass.KeyDown
        If e.KeyCode = Keys.Enter Then
            btnLogin.PerformClick()
        End If
    End Sub

    Private Sub frmLogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtUser.Text = username
        txtPass.Text = password
        CheckEditAuto.Checked = auto_login

    End Sub
End Class